/**
 * 
 */
package stc.skymobi.content.transformer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import stc.skymobi.content.Bean2PathTransformer;
import stc.skymobi.content.Path2ContentTransformer;
import stc.skymobi.util.Transformer;


/**
 * @author hp
 *
 */
public class DefaultBean2ContentTransformer implements Transformer<Object, Object> {
	
    private static final Logger logger = 
    	LoggerFactory.getLogger(DefaultBean2ContentTransformer.class);

	private	Bean2PathTransformer	bean2path;
	private	Path2ContentTransformer	path2content;
	
	/* (non-Javadoc)
	 * @see com.skymobi.util.Transformer#transform(java.lang.Object)
	 */
	public Object transform(Object requestBean) {
        String  path = bean2path.transform(requestBean);
        
        if ( null != path ) {
            if ( logger.isDebugEnabled() ) {
            	logger.debug("transform: " + requestBean + "->" + path);
            }
            return	path2content.transform(path);
        }
        else {
            if ( logger.isDebugEnabled() ) {
            	logger.debug("transform: can't found path for " + requestBean);
            }
        }
        
        return	null;
	}

	public Bean2PathTransformer getBean2path() {
		return bean2path;
	}

	public void setBean2path(Bean2PathTransformer bean2path) {
		this.bean2path = bean2path;
	}

	public Path2ContentTransformer getPath2content() {
		return path2content;
	}

	public void setPath2content(Path2ContentTransformer path2content) {
		this.path2content = path2content;
	}

}
